import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import {rules} from '/@/utils/helper/validator';
import {render} from '/@/utils/common/renderUtils';
import {getWeekMonthQuarterYear} from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
	{
		title: 'IMEI号码',
		align: 'center',
		dataIndex: 'imei',
	},

	{
		title: '充电桩名称',
		align: 'center',
		dataIndex: 'stakeName',
	},
	{
		title: '所属运营商',
		align: 'center',
		dataIndex: 'operatorId_dictText',
	},
	{
		title: '所属省市',
		align: 'center',
		dataIndex: 'areaArray',
	},
	{
		title: '桩类型',
		align: 'center',
		dataIndex: 'stakeType_dictText',
		slots: {customRender: 'poleType_dictText'},
	},
	{
		title: '额定功率（千瓦）',
		align: 'center',
		sorter: true,
		dataIndex: 'ratedPower',
	},
	{
		title: '是否双枪',
		align: 'center',
		dataIndex: 'doubleGun_dictText',
	},
	{
		title: '所属充电站',
		align: 'center',
		dataIndex: 'stationId_dictText',
	},
	{
		title: '站点地址',
		align: 'center',
		dataIndex: 'stationAddress',
	},
	{
		title: '桩状态',
		align: 'center',
		dataIndex: 'status_dictText',
		slots: {customRender: 'status_dictText'},
	},
	{
		title: '建档日期',
		align: 'center',
		dataIndex: 'establishmentDate',
		customRender: ({text}) => {
			text = !text ? '' : text.length > 10 ? text.substr(0, 10) : text;
			return text;
		},
	},
	{
		title: '最小输出电压（千伏）',
		align: 'center',
		dataIndex: 'minOutputVoltage',
	},
	{
		title: '最大输出电压（千伏）',
		align: 'center',
		dataIndex: 'maxOutputVoltage',
	},
	{
		title: '最小输出电流（安）',
		align: 'center',
		dataIndex: 'minOutputCurrent',
	},
	{
		title: '最大输出电流（安）',
		align: 'center',
		dataIndex: 'maxOutputCurrent',
	},
];
//查询数据
export const searchFormSchema: FormSchema[] = [


	{
		label: 'IMEI号码',
		field: 'imei',
		component: 'JInput',
		//colProps: {span: 6},
	},
	{
		label: '所属运营商',
		field: 'operatorId',
		component: 'Select',
		slot: 'operatorIdSlot',
	},
	{
		label: '所属充电站',
		field: 'stationId',
		component: 'Select',
		slot: 'stationIdSlot',
	},
	{
		label: '桩类型',
		field: 'stakeType',
		component: 'JDictSelectTag',
		componentProps: {
			dictCode: 'poleType',
		},
	},
	{
		label: '是否双枪',
		field: 'doubleGun',
		component: 'JDictSelectTag',
		componentProps: {
			dictCode: 'dual_gun',
		},
		//colProps: {span: 6},
	},

	{
		label: '桩状态',
		field: 'status',
		component: 'JDictSelectTag',
		componentProps: {
			dictCode: 'stakestatus',
		},
		//colProps: {span: 6},
	},
	{
		label: '所属省市',
		field: 'areaArray',
		component: 'JAreaLinkage',
		componentProps: {},
		//colProps: {span: 6},
	},
];
//表单数据
export const formSchema: FormSchema[] = [
	{
		label: 'IMEI号码',
		field: 'imei',
		component: 'Input',
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入IMEI号码!'}];
		},
	},
	{
		label: '充电桩名称',
		field: 'stakeName',
		component: 'Input',
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入充电桩名称!'}];
		},
	},
	{
		label: '所属充电站',
		field: 'stationId',
		component: 'Select',
		slot: 'stationIdSlot2',
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入所属充电站!'}];
		},
	},
	{
		label: '所属运营商',
		field: 'operatorId',
		component: 'Select',
		slot: 'operatorIdSlot2',
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入所属运营商!'}];
		},
		// defaultValue: '184184145679328051123123',
	},
	{
		label: '建档日期',
		field: 'createTime',
		component: 'DatePicker',
	},
	{
		label: '站点地址',
		field: 'stationAddress',
		component: 'Input',
	},
	{
		label: '桩类型',
		field: 'stakeType',
		component: 'JDictSelectTag',
		componentProps: {
			dictCode: 'poleType',
			stringToNumber: true,
		},
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入桩类型!'}];
		},
	},
	{
		label: '额定功率（千瓦）',
		field: 'ratedPower',
		component: 'InputNumber',
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入额定功率（千瓦）!'}];
		},
	},
	{
		label: '是否双枪',
		field: 'doubleGun_dictText',
		component: 'JDictSelectTag',
		componentProps: {
			dictCode: 'dual_gun',
			// type: 'radio',
		},
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入是否双枪!'}];
		},
	},

	{
		label: '桩状态11',
		field: 'status_dictText',
		component: 'JDictSelectTag',
		componentProps: {
			dictCode: 'stakestatus',
		},
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入桩状态!'}];
		},
	},
	{
		label: '最小输出电压（千伏）',
		field: 'minOutputVoltage',
		labelWidth: 160,
		component: 'InputNumber',
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入最小输出电压（千伏）!'}];
		},
	},
	{
		label: '最大输出电压（千伏）',
		labelWidth: 160,
		field: 'maxOutputVoltage',
		component: 'InputNumber',
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入最大输出电压（千伏）!'}];
		},
	},
	{
		label: '最小输出电流（安）',
		field: 'minOutputCurrent',
		labelWidth: 160,
		component: 'InputNumber',
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入最小输出电流（安）!'}];
		},
	},
	{
		label: '最大输出电流（安）',
		field: 'maxOutputCurrent',
		labelWidth: 160,
		component: 'InputNumber',
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入最大输出电流（安）!'}];
		},
	},

	// TODO 主键隐藏字段，目前写死为ID
	{
		label: '',
		field: 'id',
		component: 'Input',
		show: false,
	},
];

// 高级查询数据
export const superQuerySchema = {
	// imei: {title: 'IMEI号码', order: 0, view: 'text', type: 'string'},
	// stationId: {title: '所属充电站', order: 2, view: 'number', type: 'string'},
	// stakeType: {title: '桩类型', order: 5, view: 'number', type: 'number', dictCode: 'poleType'},
	// dualGun: {title: '是否双枪', order: 7, view: 'number', type: 'number', dictCode: 'dual_gun'},
	// operatorId: {title: '所属运营商', order: 8, view: 'number', type: 'number'},
	// status: {title: '桩状态', order: 9, view: 'number', type: 'number', dictCode: 'stakestatus'},
	// areaArray: {title: '所属省市', order: 14, view: 'pca', type: 'string'},
};

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
	// 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
	return formSchema;
}
